//
//  ESTPickerTipView.m
//  ESTSCRMAPP
//
//  Created by 李贤立 on 2018/9/30.
//  Copyright © 2018年 Capfer. All rights reserved.
//

#import "ESTPickerTipView.h"
#import "TYZPickerTool.h"
@interface ESTPickerTipView ()
/**
 *  图片名称
 */
@property(nonatomic, copy) NSString *imageName;
/**
 *  文字颜色
 */
@property(nonatomic, strong) UIColor *color;

@end

@implementation ESTPickerTipView

- (instancetype)init {
    if (self = [super init]) {
        self.imageModel = CustomButtonMode_Right;
        self.textColor = PickerTipViewTextColor_Black;
        [self addTarget:self action:@selector(didClickCoverButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}
- (void)didClickCoverButton {
    if (self.didClickCoverBlock) {
        self.didClickCoverBlock();
    } else {
        WEAKSELF
        [TYZPickerTool showPickerWithTitle:self.pickerTitle dataArray:self.dataArray selectedValue:self.selectedValue complement:^(NSArray<NSNumber *> *numberArray) {
            if (weakSelf.didChooseNumberBlock) {
                weakSelf.didChooseNumberBlock(numberArray);
            }
        }];
    }
}
- (void)setTitle:(NSString *)title {
    [self setTitle:title forState:UIControlStateNormal];
    self.imageModel = CustomButtonMode_Right;
}
- (void)setTextColor:(ESTPickerTipViewTextColor)textColor {
    NSString *imageName = @"";
    UIColor *color;
    switch (textColor) {
        case PickerTipViewTextColor_White:
            color = TYZWhiteColor;
            if (CoreInfo.scrmType == SCRM_TYPE_MANAGER) {
                imageName = @"arrow_down_00";
            } else {
                imageName = @"arrow_down_0-1";
            }
            break;
        case PickerTipViewTextColor_Black:
            color = TYZBlackColor;
            imageName = @"arrow_down_1";
            break;
        case PickerTipViewTextColor_Blue:
            color = TYZBlueColor;
            imageName = @"arrow_down_2";
            break;
        case PickerTipViewTextColor_Gray:
            color = TYZLightMMColor;
            imageName = @"arrow_down_3";
            break;
        case PickerTipViewTextColor_333:
            color = TYZSameColor(0x33);
            imageName = @"arrow_down_333";
            break;
        case PickerTipViewTextColor_666:
            color = TYZSameColor(0x66);
            imageName = @"arrow_down_666";
            break;
        case PickerTipViewTextColor_999:
            color = TYZSameColor(0x99);
            imageName = @"arrow_down_999";
            break;
        case PickerTipViewTextColor_Theme:
            color = ThemeColor;
            if (CoreInfo.scrmType == SCRM_TYPE_MANAGER) {
                imageName = @"arrow_down_manager";
            } else {
                imageName = @"arrow_down_assistant";
            }
            break;
        default:
            break;
    }
    self.color = color;
    self.imageName = imageName;
    [self setTitleColor:color forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    self.imageModel = CustomButtonMode_Right;
}
@end
